//
//  P1135.cpp
//  Algorithm
//
//  Created by 刘锦程 on 2023/9/7.
//

#include <stdio.h>
#include<iostream>
#include<cstdio>
using namespace std;
int n,A,B,mins=2147483647,step;
int floor[202],book[202];
void input(){
    scanf("%d",&n);
    scanf("%d%d",&A,&B);
    for(int i=1;i<=n;i++){
        scanf("%d",&floor[i]);
    }
}
bool canup(int f){
    return f+floor[f]<=n;
}
bool candown(int f){
    return f-floor[f]>=1;
}
void searchf(int f,int step){
    if(f==B){
        mins=min(mins,step);
        return;
    }else{
        book[f]=1;
        if(canup(f)&&!book[f+floor[f]]){
            searchf(f+floor[f],step+1);
        }
        if(candown(f)&&!book[f-floor[f]]){
            searchf(f-floor[f],step+1);
        }
        book[f]=0;
    }
}
void P1135ans(){
    input();
    searchf(A,0);
    if(mins!=2147483647)
    printf("%d\n",mins);
    else cout<<-1<<endl;
}
